package com.atguigu.ggkt.vod.controller;

import com.atguigu.ggkt.result.Result;
import com.atguigu.ggkt.vod.service.VodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("腾讯云点播")
@RestController
@RequestMapping("admin/vod/")
//@CrossOrigin
public class VodController {

    @Autowired
    private VodService vodService;

    @ApiOperation("获得客户端上传视频的签名")
    @GetMapping("sign")//注意这里是Get
    public Result sign(){
        String sign = vodService.sign();
        return Result.ok(sign);
    }

    @ApiOperation("视频上传接口")
    @PostMapping("upload")
    public Result upload(){
        String fileId =  vodService.uploadVideo();//返回被上传视频的id
        return Result.ok(fileId);
    }

    @ApiOperation("视频删除")
    @DeleteMapping("remove/{fileId}")
    public Result remove(@PathVariable String fileId){
        vodService.removeVideo(fileId);//返回被上传视频的id
        return Result.ok(null);
    }
}
